<?php

/**
 * Class for generating a PDF file - inside of the "newspaper"
 *
 * @author mario
 */
class InsidePDF extends TCPDF {

    protected $colwidth = 125;

    private function PrintArticles($txt_left,$txt_right) {
	$this->AddPage('L','A4');
	$this->SetFont('dejavuserif', '', 8.5);
	$this->writeHTMLCell($this->colwidth, 0,15,10,$txt_left,0,1,0,false,'J');
	$this->writeHTMLCell($this->colwidth, 0,160,10,$txt_right,0,1,0,false,'J');
    }

    public function PrintPage() {
	$this->SetCreator(PDF_CREATOR);
	$this->SetAuthor('webnews');
	$this->SetTitle("LETAK 1/2");
	$this->SetSubject('LETAK');
	$this->setPrintHeader(false);
	$this->setPrintFooter(false);
	$this->SetAutoPageBreak(TRUE, 10);
	$this->setMargins(10,10,10);

	$articles = Doctrine::getTable('Article')->getArticles();
	$txt_left = "";
	$txt_right = "";
	foreach ($articles as $num => $article) {
	    if ($num<2) {
		$txt_left .= "<h2>".$article->getTitle()."</h2><div class=\"pdfsmall\">dsdsd".$article->getUser()."</div>";
		$txt_left .= $article->getContent()."<br>";
	    } elseif ($num<4) {
		$txt_right .= "<h2>".$article->getTitle()."</h2>";
		$txt_right .= $article->getContent()."<br>";
	    }
	}
	$this->PrintArticles($txt_left, $txt_right);
    }

}

?>
